-
-
Notifications
You must be signed in to change notification settings - Fork 12
refactor(validation): clean up validation functions #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Claude finished @ymc9's task —— View job Code Review Complete ✅I'll review this validation functions refactoring PR and provide feedback on code quality, potential issues, performance, security, and test coverage. Todo List
SummaryThis is a well-structured refactoring that enhances the validation system by adding new validation functions and improving existing ones. The changes are focused and maintain good separation of concerns. Issues Found🐛 Critical BugMissing if (!fieldArg.$resolvedType?.array && fieldArg.$resolvedType?.decl !== 'String') {
accept('error', msg, {
node: expr.args[0]!,
});
// Missing return here - execution continues after error
}
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds ListField support and list-aware validations: updates stdlib signatures and validator names, extends language validators for length/regex on strings/lists, introduces runtime array validation helpers, adapts CRUD schema generation, and updates end-to-end tests and TODOs. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1){packages,samples,tests}/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)packages/runtime/src/client/crud/validator/index.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors validation functions to improve consistency and functionality. The changes update function naming conventions to use is* prefixes for boolean validators, enhance the length() function to support both strings and lists, and add comprehensive validation for function arguments at compile-time.
Key changes:
- Renamed validation functions (
email→isEmail,url→isUrl,datetime→isDateTime) - Enhanced
length()function to return an integer value and support both string and list fields - Added compile-time validation for function arguments (type checking for
length()andregex())
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/language/res/stdlib.zmodel | Updated function signatures and documentation for validation functions |
| packages/runtime/src/client/crud/validator/utils.ts | Added addListValidation() function and updated length() evaluation logic |
| packages/runtime/src/client/crud/validator/index.ts | Integrated list validation into schema generation for array fields |
| packages/language/src/validators/function-invocation-validator.ts | Added compile-time validators for length() and regex() functions |
| packages/language/src/validators/attribute-application-validator.ts | Added ListField as valid target for @length attribute |
| tests/e2e/orm/validation/toplevel.test.ts | Added test coverage for @length attribute on list fields |
| tests/e2e/orm/validation/custom-validation.test.ts | Updated tests to use new function names and added argument type validation tests |
| TODO.md | Marked validation tasks as completed |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Claude finished @ymc9's task —— View job Code Review Complete ✅I'll review this validation functions refactoring PR and provide feedback on code quality, potential issues, performance, security, and test coverage. Todo List
SummaryThis is a well-structured refactoring that enhances the validation system by adding new validation functions and improving existing ones. The changes are focused and maintain good separation of concerns. Issues Found🐛 Critical BugMissing if (!fieldArg.$resolvedType?.array && fieldArg.$resolvedType?.decl !== 'String') {
accept('error', msg, {
node: expr.args[0]!,
});
// Missing return here - execution continues after error
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
TODO.md(2 hunks)packages/language/res/stdlib.zmodel(4 hunks)packages/language/src/validators/attribute-application-validator.ts(1 hunks)packages/language/src/validators/function-invocation-validator.ts(2 hunks)packages/runtime/src/client/crud/validator/index.ts(3 hunks)packages/runtime/src/client/crud/validator/utils.ts(3 hunks)tests/e2e/orm/validation/custom-validation.test.ts(6 hunks)tests/e2e/orm/validation/toplevel.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
{packages,samples,tests}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place packages only under
packages/,samples/, ortests/
Files:
packages/language/src/validators/attribute-application-validator.tspackages/language/src/validators/function-invocation-validator.tstests/e2e/orm/validation/custom-validation.test.tstests/e2e/orm/validation/toplevel.test.tspackages/runtime/src/client/crud/validator/utils.tspackages/language/res/stdlib.zmodelpackages/runtime/src/client/crud/validator/index.ts
tests/e2e/**
📄 CodeRabbit inference engine (CLAUDE.md)
End-to-end tests must live under
tests/e2e/
Files:
tests/e2e/orm/validation/custom-validation.test.tstests/e2e/orm/validation/toplevel.test.ts
🧬 Code graph analysis (5)
packages/language/src/validators/attribute-application-validator.ts (1)
packages/language/src/generated/ast.ts (1)
isDataModel(391-393)
packages/language/src/validators/function-invocation-validator.ts (2)
packages/language/src/generated/ast.ts (4)
InvocationExpr(533-538)InvocationExpr(540-540)isDataModel(391-393)isStringLiteral(709-711)packages/language/src/utils.ts (1)
isDataFieldReference(137-139)
tests/e2e/orm/validation/toplevel.test.ts (1)
packages/testtools/src/client.ts (1)
createTestClient(52-169)
packages/runtime/src/client/crud/validator/utils.ts (2)
packages/sdk/src/schema/schema.ts (1)
AttributeApplication(39-42)packages/common-helpers/src/tiny-invariant.ts (1)
invariant(4-14)
packages/runtime/src/client/crud/validator/index.ts (1)
packages/runtime/src/client/crud/validator/utils.ts (1)
addListValidation(206-230)
🪛 ast-grep (0.39.6)
packages/language/src/validators/function-invocation-validator.ts
[warning] 225-225: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(regex.value)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
🪛 markdownlint-cli2 (0.18.1)
TODO.md
88-88: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
|
Claude finished @ymc9's task —— View job Code Review Complete ✅I'll review this validation functions refactoring PR and provide feedback on code quality, potential issues, performance, security, and test coverage. Todo List
SummaryThis is a well-structured refactoring that enhances the validation system by adding new validation functions and improving existing ones. The changes are focused and maintain good separation of concerns. Issues Found🐛 Critical BugMissing if (!fieldArg.$resolvedType?.array && fieldArg.$resolvedType?.decl !== 'String') {
accept('error', msg, {
node: expr.args[0]!,
});
// Missing return here - execution continues after error
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/runtime/src/client/crud/validator/index.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{packages,samples,tests}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place packages only under
packages/,samples/, ortests/
Files:
packages/runtime/src/client/crud/validator/index.ts
🧬 Code graph analysis (1)
packages/runtime/src/client/crud/validator/index.ts (1)
packages/runtime/src/client/crud/validator/utils.ts (1)
addListValidation(206-230)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: claude-review
🔇 Additional comments (2)
packages/runtime/src/client/crud/validator/index.ts (2)
48-48: LGTM!The import of
addListValidationis correctly added to support list-level validation for array fields.
908-916: LGTM!The array field handling in the create path correctly applies list-level validation (via
addListValidation) to both the direct array assignment and thesetoperation. Array elements are properly required (not optional) as expected for create operations.
|
Claude finished @ymc9's task —— View job Code Review Complete ✅I'll review this validation functions refactoring PR and provide feedback on code quality, potential issues, performance, security, and test coverage. Todo List
SummaryThis is a well-structured refactoring that enhances the validation system by adding new validation functions and improving existing ones. The changes are focused and maintain good separation of concerns. Issues Found🐛 Critical BugMissing if (!fieldArg.$resolvedType?.array && fieldArg.$resolvedType?.decl !== 'String') {
accept('error', msg, {
node: expr.args[0]!,
});
// Missing return here - execution continues after error
}
|
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores